﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BootStrap.HtmlHelper.Sample.Models;

namespace BootStrap.HtmlHelper.Sample.Controllers
{
	public class FormController : Controller
	{
		//
		// GET: /Form/

		public ActionResult Index()
		{
			// create list of makes
			List<SelectListItem> makes = new List<SelectListItem>();
			makes.Add(new SelectListItem { Text = "BMW", Value = "1" });
			makes.Add(new SelectListItem { Text = "VW", Value = "2" });
			makes.Add(new SelectListItem { Text = "Ford", Value = "3" });
			makes.Add(new SelectListItem { Text = "Toyota", Value = "4" });

			return View(new FormModel
				{
					Makes = makes,
					MakeId = 3
				}
			);
		}

		[HttpPost]
		public ActionResult Index(FormModel model)
		{
			if(!ModelState.IsValid)
				return View(model);

			return RedirectToAction("Success");
		}

		public ActionResult Success()
		{
			return View();
		}
	}
}
